home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c,comp.std.c
- Subject: Re: Integral conversion e.t.c. (was: Re: Hungarian notation)
- Date: 29 Jan 1996 16:05:18 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Jan29090518@qcd.lanl.gov>
- References: <30C40F77.53B5@swsbbs.com> <SPENCER.96Jan22113215@zorgon.ERA.COM>
- <KANZE.96Jan26164833@gabi.gabi-soft.fr> <DLtABq.Fzu@mv.mv.com>
- <4edqh2$rvl@solutions.solon.com>
- <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: kanze@lts.sel.alcatel.de's message of 29 Jan 1996 11:19:56 GMT
-
- In article <KANZE.96Jan29121956@slsvewt.lts.sel.alcatel.de>
- kanze@lts.sel.alcatel.de (James Kanze US/ESC 60/3/141 #40763) writes:
- <snip>
- I think the crux of Michael Furman's question lies therein. Does the
- standard require a diagnostic if the function main is not of one of
- the two types given?
-
- No diagnostic is _required_, but irrespective of whether a diagnostic
- is produced, there is no guarantee how the program will behave. This
- is a quintessential example of undefined behaviour. An implementation
- is free to define whatever meaning it chooses for this, exactly as it
- is free to change the meaning of the entire rest of the program based
- on this one statement.
-
- To tell the truth, I'm not sure what the answer is. The text
- concerning main is in the chapter describing the environment. It
- doesn't appear as a semantic restriction or anything. It simply
- states that on start-up, a function called main will be called, and
- that the implementation must support the following forms. It doesn't
- seem (to me, at least) to say anything about what other forms it might
- support, or what the implementation must do if given a fully other
- definition of main.
-
- And hence, it is an undefined behaviour.
-
- Normally, I would expect (at the very least) a compiler to generate a
- warning or an error for a main that it did not support. In fact,
- however, my compiler (gcc) accepts the following definition without
- the slightest complaint, although I'd rather not think about what will
- happen when I access parameter d:
-
- int main( char a , int b , long c , double d )
-
- Undefined behaviour does not need diagnostic.
-
- |> For purposes of the C newsgroups, discussion of what is/isn't legal
- |> is generally restricted to strictly conforming C.
-
- Yes and no. In comp.std.c, the discussion is exactly about what is
- legal according to the standard. In comp.lang.c (to which this
- article is also cross-posted), the discussion should generally be a
- bit more open.
-
- Thus, for example, in comp.std.c, a program with a variable named far
- is illegal, and that is it. In comp.lang.c (and I hope in its
-
- Huh? A variable named far is perfectly legal.
-
- moderated variant), I would hope that someone would point out that,
- legal or not, it's going to get you into trouble.
-
- I hope that situation changes soon in the future. Implementation
- extensions must not encroach upon user name space: the C standard
- attempts to formalize the distinction between user and implementation
- name spaces: compilers ought to follow it. Not only in law, but also
- in spirit.
-
- For example, assuming that the concept of a far pointer is truly
- required (It is really an exceptional circumstance which truly
- _requires_ it; a compiler should usually figure out whether a near or
- far pointer will work better: but that is a separate discussion), a
- compiler should invent a keyword in the implementation name space
- (e.g. __far) for it. It may provide a non-default switch
- /backward-compatible to allow it to recognize far as a keyword and
- treat it as a syntax error if used as a variable name.
-
- But I agree that discussions in comp.lang.c should also take care of
- current realities, even if those realities are fossils of an era long
- past, frozen in time only by the arrogant ignorance of a large body of
- users with a narrow view to the future.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-